#!/bin/bash
set -xeuo pipefail
BASE_DIR=$(cd "$(dirname "$0")"; pwd)
cd ${BASE_DIR}

:<<EOF
https://hub.docker.com/r/gradiant/hdfs
https://github.com/Gradiant/dockerized-hadoop
docker pull gradiant/hdfs:3.2.1

Example of a hdfs sinlge namenode and three datanodes.

docker run -d --name hdfs-namenode gradiant/hdfs-namenode:3.2.1
docker run -d --link hdfs-namenode --name hdfs-datanode1 -e CORE_CONF_fs_defaultFS=hdfs://hdfs-namenode:8020 gradiant/hdfs-datanode

Testing: creating and listing and example folder in hdfs
docker exec -ti hdfs-namenode hdfs dfs -mkdir /example
docker exec -ti hdfs-namenode hdfs dfs -ls /

http://localhost:9870/ 这个可以查看HDFS的状态
EOF

if [ -f pkg/repository-hdfs-7.8.0.zip ]; then
 echo "ES HDFS plugin must be existed"
 exit 1
fi

docker-compose -f hdfs.yml up

echo "done"
